<template>
  <!-- 劳务人员管理 -->
  <base-breadcrumb>
    <searchData :searchData="searchOptions" />
    <div class="page-body">
      <a-card :bordered="false">
        <title-name title="劳务人员名单" />
        <div class="table-operateors mb20">
          <a-button type="primary" @click="handleUpdate('add')">手动录入</a-button>
          <a-button>同步云筑</a-button>
          <a-button>批量导入</a-button>
          <a-button>模板下载</a-button>
        </div>
        <s-table
          :scroll="{ x: 1800 }"
          ref="table"
          size="default"
          rowKey="key"
          :columns="columns"
          :data="loadData"
          :alert="true"
          show-size-changer
          show-quick-jumper
          showPagination="auto"
        >
          <template slot="operator" slot-scope="text, record">
            <a class="base-btn" @click="handleOperate('edit', record)">编辑</a>
          </template>
        </s-table>
      </a-card>
    </div>
    <!-- 增改弹窗 -->
    <update-laborer v-if="visible.update" @cancel="visible.update = false" />
  </base-breadcrumb>
</template>

<script>
import UpdateLaborer from './UpdateLaborer.vue'
import { STable } from '@/components'
import ThemeChoose from '@/components/themeChoose/themeChoose.vue'
import { getConstructionProgressList, getTwoImplementation } from '@/api/construction/planInput'
export default {
    name:'a'+Date.now(),  components: {
    ThemeChoose,
    STable,
    UpdateLaborer,
  },
  data() {
    return {
      searchOptions: [
        {
          name: '所属分公司',
          value: 'companyName',
          type: 'select',
        },
        {
          name: '所属项目',
          value: 'projectName',
          type: 'select',
        },
        {
          name: '分包单位',
          value: 'unitName',
          type: 'select',
        },
        {
          name: '人员姓名',
          value: 'personName',
          type: 'input',
        },
        {
          name: '特种作业',
          value: 'specialWork',
          type: 'select',
        },
      ],
      formConfig: {},
      visible: {
        update: false,
      },
      state: {
        isExpand: false,
      },
      formInfo: this.$form.createForm(this, { name: 'searchForm' }),
      columns: [
        {
          title: '姓名',
          dataIndex: 'name',
        },
        {
          title: '分包商',
          dataIndex: 'subBusiness',
        },
        {
          title: '班组',
          dataIndex: 'groupName',
        },
        {
          title: '工种',
          dataIndex: 'workType',
        },
        {
          title: '身份证号码',
          dataIndex: 'idCard',
        },
        {
          title: '性别',
          dataIndex: 'sex',
        },
        {
          title: '联系电话',
          dataIndex: 'phone',
        },
        {
          title: '出生日期',
          dataIndex: 'bornDate',
        },
        {
          title: '状态',
          dataIndex: 'status',
        },
        {
          title: ' 操作',
          dataIndex: 'operator',
          scopedSlots: { customRender: 'operator' },
        },
      ],
      queryParam: {},
      loadData: (parameter) => {
        const requestParameters = Object.assign({}, parameter, this.queryParam)
        return new Promise((resolve, reject) => {
          resolve({
            currentPage: 1,
            totalSize: 5,
            data: [
              {
                name: 'z1',
                subBusiness: '分包商1',
                groupName: '班组1',
                workType: '工种1',
                idCard: '513022199922335566',
                sex: 'man',
                phone: '13022221111',
                bornDate: '2020-20-20',
                status: 'normal',
              },
              {
                name: 'z2',
                subBusiness: '分包商2',
                groupName: '班组1',
                workType: '工种1',
                idCard: '513022199922335566',
                sex: 'man',
                phone: '13022221111',
                bornDate: '2020-20-20',
                status: 'normal',
              },
              {
                name: 'z3',
                subBusiness: '分包商3',
                groupName: '班组1',
                workType: '工种1',
                idCard: '513022199922335566',
                sex: 'man',
                phone: '13022221111',
                bornDate: '2020-20-20',
                status: 'normal',
              },
              {
                name: 'z4',
                subBusiness: '分包商4',
                groupName: '班组1',
                workType: '工种1',
                idCard: '513022199922335566',
                sex: 'man',
                phone: '13022221111',
                bornDate: '2020-20-20',
                status: 'normal',
              },
              {
                name: 'z5',
                subBusiness: '分包商5',
                groupName: '班组1',
                workType: '工种1',
                idCard: '513022199922335566',
                sex: 'man',
                phone: '13022221111',
                bornDate: '2020-20-20',
                status: 'normal',
              },
            ],
          })
        })
      },
    }
  },
  methods: {
    // 处理更新操作（新增、编辑）
    handleUpdate(type, data = {}) {
      this.visible.update = true
    },
    handleGetThemes(data) {
      console.log(data)
      console.log('zzz', this.formInfo.getFieldsValue())
    },
    handleOperate(type, data) {
      console.log(type, data)
    },
  },
}
</script>

<style lang="less" scoped>
.page-header {
  .header-row {
    display: flex;
    .flex-content {
      flex: auto;
    }
    .divider {
      margin: 0 12px;
    }
    .expand-btn {
      margin-left: 8px;
      font-size: 14px;
    }
  }
}
.page-body {
  .table-operateors {
    .ant-btn + .ant-btn {
      margin-left: 12px;
    }
  }
}
</style>